package com.example.easybuy.pojo;

import org.springframework.stereotype.Component;

import java.util.List;

/**
 * solr的分页
 * @param <T>
 */
@Component
public class SolrPage<T> {
    //当前页码
    private int currentPage=1;
    //总条数
    private int totalCount=0;
    //容量
    private int pageSize=16;
    //总页数
    private int totalPageCount=0;
    //一页的数据
    private List<T> list;

    public int getCurrentPage() {
        return currentPage;
    }


    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotalCount() {
        return totalCount;
    }

//    计算总页数
    public void getSumPage(){
        if(this.totalCount%this.pageSize==0){
            this.totalPageCount=this.totalCount/this.pageSize;
        }else if(this.totalCount%this.pageSize!=0){
            this.totalPageCount=this.totalCount/this.pageSize+1;
        }
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
        this.getSumPage();
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "SolrPage{" +
                "currentPage=" + currentPage +
                ", totalCount=" + totalCount +
                ", pageSize=" + pageSize +
                ", totalPageCount=" + totalPageCount +
                ", list=" + list +
                '}';
    }
}
